package com.linkage.jz.bankruptcy.bean;

import android.text.TextUtils;

import com.google.gson.Gson;
import com.google.gson.JsonArray;
import com.google.gson.JsonObject;

import java.util.ArrayList;
import java.util.List;

/**
 * @author AFAP
 * 讨论
 */
public class ProTalk {

    private String id; // 话题id
    private String username; // 用户名
    private String avatar; // 头像
    private String subjectTitle; // 话题标题
    private String subjectType; // 话题类型 0-债委会话题; 1-债权人话题
    private long createTime; // 创建时间
    private int cnt; // 回复数
    private boolean hasPictures; // 是否有图片


    public String getId() {
        return id;
    }

    public void setId(String id) {
        this.id = id;
    }

    public String getUsername() {
        return username;
    }

    public void setUsername(String username) {
        this.username = username;
    }

    public String getAvatar() {
        return avatar;
    }

    public void setAvatar(String avatar) {
        this.avatar = avatar;
    }

    public String getSubjectTitle() {
        return subjectTitle;
    }

    public void setSubjectTitle(String subjectTitle) {
        this.subjectTitle = subjectTitle;
    }

    public String getSubjectType() {
        return subjectType;
    }

    public void setSubjectType(String subjectType) {
        this.subjectType = subjectType;
    }

    public long getCreateTime() {
        return createTime;
    }

    public void setCreateTime(long createTime) {
        this.createTime = createTime;
    }

    public int getCnt() {
        return cnt;
    }

    public void setCnt(int cnt) {
        this.cnt = cnt;
    }

    public boolean isHasPictures() {
        return hasPictures;
    }

    public void setHasPictures(boolean hasPictures) {
        this.hasPictures = hasPictures;
    }

    public static List<ProTalk> parse(JsonArray arr) {
        List<ProTalk> list = new ArrayList<>();
        for (int i = 0; i < arr.size(); i++) {
            list.add(parse(arr.get(i).getAsJsonObject()));
        }
        return list;
    }

    public static ProTalk parse(JsonObject obj) {
        ProTalk bean = new Gson().fromJson(obj, ProTalk.class);
        if (TextUtils.isEmpty(bean.getAvatar())) {
            bean.setAvatar("NA");
        }
        return bean;
    }

}
